import Vue from "vue";
import VueRouter from "vue-router";

import HomeTwo from '@/pages/Home/HomeTwo.vue';


// 声明使用vue插件
Vue.use(VueRouter);
export default new VueRouter({
    mode:"hash",//模式 路径后面 #
    // mode:"history",// 不加#
    routes:[//routes注册路由组件
        {
            path:'/home',//路径 /  
            name:'home',//路由组件的名字
            // component:()=>import('@/pages/Home.vue')
            components:{
                default:()=>import('@/pages/Home.vue'),
                HomeOne:()=>import('@/pages/Home/HomeOne.vue'),
                HomeTwo
            }
            // 命名视图  一个路由路径 对应多个router-view
        },
        // 嵌套路由
        {
            path:'/cate',
            name:"cate",
            // component:()=>import('@/pages/Cate.vue'),
            components:{
                default:()=>import('@/pages/Cate.vue'),
                HomeOne:()=>import('@/pages/Home/HomeOne.vue')
            },
            children:[
                {
                    //注意：路径的写法可以全写 也可以简写注意不要在最前面加 /
                    // path:'/cate/catechildone',
                    path:'catechildone',
                    name:'catechildone',
                    component:()=>import('@/pages/CateChildOne.vue'),
                    children:[
                        {
                            // path:'/cate/catechildone/catechildsonone',
                            path:'catechildsonone',
                            name:'catechildsonone',
                            component:()=>import('@/pages/CateChildSonOne.vue')
                        }
                    ]
                }
            ]
        },
        {
            path:'/search',
            name:'search',//路由名字
            component:()=>import('@/pages/Search.vue'),
            // 别名
            alias:'/sousuo',
            children:[
                {
                    // path:'/search/detail/:stu_id/:student',
                    // path:'/search/detail',
                    path:'/search/detail/:stu_id',

                    name:'detail',
                    component:()=>import('@/pages/Detail.vue')
                }
            ]
        },
        {
            path:'/my',
            name:'my',
            component:()=>import('@/pages/My.vue')
        },
        // 路由重定向
        {
            path:'/',
            // redirect后面可以跟对象也可以跟字符串
           /*  redirect:{
                // name:'cate'
                path:'/home'
            } */
            redirect:'/home'
        }
    ]
})


